package com.example.consumer.controller;

import com.example.consumer.feign.UserFeignClient;
import com.example.consumer.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/consumer/users")
public class UserConsumerController {

    @Autowired
    private UserFeignClient userFeignClient;

    @GetMapping
    public List<User> getAllUsers() {
        return userFeignClient.getAllUsers();
    }

    @GetMapping("/{id}")
    public User getUserById(@PathVariable Long id) {
        return userFeignClient.getUserById(id);
    }

    @PostMapping
    public User createUser(@RequestBody User user) {
        return userFeignClient.createUser(user);
    }

    @PutMapping("/{id}")
    public User updateUser(@PathVariable Long id, @RequestBody User user) {
        return userFeignClient.updateUser(id, user);
    }

    @DeleteMapping("/{id}")
    public boolean deleteUser(@PathVariable Long id) {
        return userFeignClient.deleteUser(id);
    }
} 